package com.nxy.test.rxjava;

import io.reactivex.Flowable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class RxJava {
    private static final Logger logger = LoggerFactory.getLogger(RxJava.class);

    public static void main(String[] args) {
//        hello1();
        hello2();
    }

    private static void hello1() {
        Flowable.just(4, 5, 6)
                .startWith(Flowable.just(1, 2, 3))
                .startWith(0)
                .subscribe(ele -> logger.info("ele:{}",ele));
    }
    private static void hello2() {
        Flowable.merge(Flowable.just(1,2,3),
                Flowable.just(4,5,6))
                .reduce((last, item) -> {
                    logger.info("tag:"+ last + "," + item);
                    return last + item;
                })
                .subscribe(ele -> logger.info("ele:{}",ele));

    }
}
